@echo off
chcp 65001 >nul
echo ========================================
echo 测试护理等级字段错误修复
echo ========================================

echo.
echo 问题：数据展示出来了，但是有报错
echo 错误：Unknown column 'e.care_level' in 'field list'
echo 原因：老人表中没有care_level字段
echo 修复：移除不存在的字段引用

echo.
echo 修复内容：
echo 1. SQL查询：移除 e.care_level as elderly_care_level
echo 2. 实体类：移除 elderlyCareLevel 属性
echo 3. ResultMap：移除 elderlyCareLevel 字段映射
echo 4. 前端：护理等级显示为固定值"未知护理等级"

echo.
echo 修复后的SQL查询：
echo SELECT 
echo     com.id, com.check_out_no, com.elderly_id, com.business_id,
echo     e.name as elderly_name,
echo     e.id_card as elderly_id_card,
echo     e.contact as elderly_contact,
echo     c.contract_name,
echo     b.bed_no as bed_number,
echo     cim.fee_start_date,
echo     cim.fee_end_date,
echo     u.nick_name as caregiver_name
echo FROM check_out_management com
echo LEFT JOIN elderly e ON com.elderly_id = e.id
echo LEFT JOIN contract c ON com.elderly_id = c.elderly_id
echo LEFT JOIN bed b ON com.bed_id = b.id
echo LEFT JOIN check_in_management cim ON com.check_in_management_id = cim.id
echo LEFT JOIN sys_user u ON com.creator = u.user_id
echo WHERE com.business_id = #{businessId}

echo.
echo 测试步骤：
echo 1. 在待办任务界面点击"吴老九退住申请"的处理按钮
echo 2. 检查是否还有SQL错误
echo 3. 检查审批页面是否正常显示
echo 4. 检查数据显示：
echo    - 老人姓名：吴老九
echo    - 签约合同：老人九合同
echo    - 护理等级：未知护理等级（固定值）
echo    - 养老顾问：ry
echo    - 护理员：ry

echo.
echo 预期结果：
echo - 不再出现SQL错误
echo - 审批页面正常显示
echo - 显示正确的申请数据
echo - 护理等级显示为"未知护理等级"（因为数据库中没有该字段）

echo.
echo 数据库查询验证：
echo SELECT com.business_id, com.elderly_id,
echo        e.name as elderly_name, e.id_card, e.contact,
echo        c.contract_name, u.nick_name as caregiver_name
echo FROM check_out_management com
echo LEFT JOIN elderly e ON com.elderly_id = e.id
echo LEFT JOIN contract c ON com.elderly_id = c.elderly_id
echo LEFT JOIN sys_user u ON com.creator = u.user_id
echo WHERE com.business_id = '72';

echo.
echo 修复完成！
pause
